<template>
  <div style="flex:1;" class="flex auto">
    <criteria-paged :model="model" v-ref:paged  @sort="sort">
      <criteria partial='criteria' v-ref:criteria @condition-changed="$parent.selfSearch">
        <div novalidate class="form-inline" partial>

          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_userinfo_id"
                   condition="f_userinfo_id='{}'" placeholder='用户编号'
                   :size="model.f_userinfo_id ? model.f_userinfo_id.length : 4">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_user_id"
                   condition="f_user_id='{}'" placeholder='表编号'
                   :size="model.f_user_id ? model.f_user_id.length : 3">
          </div>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_user_name" placeholder='用户姓名'
                    condition="f_user_name like '%{}%'"
                    :size="model.f_user_name ? model.f_user_name.length * 2 : 4">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_address"
                   condition="f_address like '%{}%'" placeholder='用户地址'
                   :size="model.f_address ? model.f_address.length * 2: 4">
          </div>
          <div class="form-group">
            <v-select :value.sync="model.f_inputtor" v-model='model.f_inputtor'
                      :options='$parent.$parent.inputtores' placeholder='抄表员'
                      close-on-select
                      condition="f_inputtor = '{}'" v-el:cc></v-select>
          </div>
          <div class="form-group">
            <v-select :value.sync="model.f_meter_state" v-model='model.f_meter_state'
                      :options='$parent.$parent.meterstates' placeholder='抄表状态'
                      close-on-select
                      condition="f_meter_state = '{}'"></v-select>
          </div>
          <div class="form-group">
            <v-select :value.sync="model.f_whether_pay" v-model='model.f_whether_pay'
                      :options='$parent.$parent.whetherpaies' placeholder='是否缴费'
                      close-on-select
                      condition="f_whether_pay = '{}'"></v-select>
          </div>
          <div class="form-group">
            <v-select :value.sync="model.f_user_type" v-model="model.f_user_type"
                      :options='$parent.$parent.usertypes' placeholder='用户类型'
                      close-on-select
                      condition="f_user_type = '{}'"></v-select>
          </div>
          <div class="form-group" >
            <v-select :value.sync="model.f_filiale" v-model='model.f_filiale'
                      :options='$parent.$parent.filiales' placeholder='分公司'
                      close-on-select
                      condition="f_filiale = '{}'"></v-select>
          </div>

          <div class="form-group">
            <v-select :value.sync="model.f_outlets" v-model='model.f_outlets'
                      :options='$parent.$parent.outlets' placeholder='营业网点'
                      close-on-select
                      condition="f_outlets = '{}'"></v-select>
          </div>
          <div class="form-group">
            <button class="btn btn-success  width-100" @click="search()">查询</button>
          </div>

          <div class="form-group" v-if="$parent.$parent.meter_state">
            <button class="btn btn-success  width-100" @click="$parent.$parent.batchDownHand()" >计划下发</button>
          </div>
          <!--<div class="form-group">-->
            <!--<button class="btn btn-success  width-100" @click="$parent.$parent.adjust()">抄表员调整</button>-->
          <!--</div>-->
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid id="test" >
        <template partial='head'>
          <tr>
            <th>序号</th>
            <th>用户编号</th>
            <th>表编号</th>
            <th>用户基本信息</th>
            <th>抄表员</th>
            <th>上次底数</th>
            <th>本次底数</th>
            <th>返还金额</th>
            <th>操作</th>
          </tr>
        </template>
        <template partial='body' >
          <td style="text-align: center;">{{$index+1}}</td>
          <td>{{row.f_userinfo_id}}</td>
          <td>{{row.f_user_id}}</td>
          <td>{{row.f_user_name}}&nbsp;&nbsp;{{row.f_phone}}&nbsp;&nbsp;{{row.f_address}}</td>
          <td>{{row.f_inputtor}}</td>
          <td>{{row.f_last_tablebase}}</td>
          <td id="hand-creat">
            <div class="form-group" style="margin-bottom:0px;" :class="{
						'has-success has-feedback': (row.f_tablebase && row.f_tablebase !== '')? ((row.f_tablebase-0) >= (row.f_last_tablebase -0)) : false,
						'has-error has-feedback': (row.f_tablebase && row.f_tablebase !== '')? ((row.f_tablebase-0) < (row.f_last_tablebase -0) ) : false}"
                 v-if="row.f_meter_state === '未抄表' && row.states !== 0">

              <input type="text" class="form-control" v-model="row.f_tablebase"  @blur="$parent.$parent.$parent.enter($index, row)"
                     v-next-el="{id: $index+1}"   :id="$index" style="width: 100px;padding: 6px;"  @focus="$parent.$parent.$parent.clearError(row)"
                     :disabled="row.state === '开始'">
              <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"
                    v-show="(row.f_tablebase && row.f_tablebase !== '')? ((row.f_tablebase-0) >= (row.f_last_tablebase -0)) : false"></span>
              <span class="hand-loading" v-if="row.state === '开始'"></span>
              <span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"
                    v-show="(row.f_tablebase && row.f_tablebase !== '')? ((row.f_tablebase-0) < (row.f_last_tablebase -0) ) : false"></span>
            </div>
            <div id="handManager" v-else>
              <span v-if="row.states === 0">{{row.f_tablebase ? row.f_tablebase : '本期无计划'}}</span>
              <span v-if="row.states === 1">{{row.f_tablebase ? row.f_tablebase : '尚未下发'}}</span>
            </div>
            <span v-if="row.error" style="color: red;">{{row.error}}</span>
          </td>
          <td>{{row.f_meter_state === '已抄表' ? row.f_return_fee : null}}</td>
          <td style="text-align: center;">
            <button type="button" name="button" class="btn btn-link"
                    v-if="row.f_meter_state === '已抄表' && row.states === 1 && row.f_oper_state === '正常'"
                    @click.stop="$parent.$parent.$parent.cancelHand(row)">冲正</button>
            <button type="button" name="button" class="btn btn-link"
                    @click.stop="$parent.$parent.$parent.delectHand(row)  && row.states === 1"
                    v-if="row.f_meter_state === '未抄表' && row.states === 1">删除</button>
            <button type="button" name="button" class="btn btn-link"
                    @click.stop="$parent.$parent.$parent.downHand(row)"
                    v-if="row.f_meter_state === '未下发'">下发计划</button>
          </td>
        </template>
      </data-grid>
    </criteria-paged>
    <div class="form-inline" v-if="isChange">
      <div class="form-group auto">
        <label>调整用户数</label>
        <input class="form-control" v-model="model.count" disabled>
      </div>
      <div class="form-group auto">
        <label>抄表员</label>
        <v-select :value.sync="changeModel.f_inputtor" v-model='changeModel.f_inputtor'
                  :options='inputtores' placeholder='抄表员'
                  close-on-select
                  condition="h.f_inputtor = '{}'" v-el:cc></v-select>
      </div>
      <button class="btn btn-success" @click="changeInputtor(changeModel.f_inputtor[0])" :disabled="changeModel.f_inputtor.length !== 1">确认</button>
      <button class="btn btn-success" @click="changeCancel()">取消</button>
    </div>

    <modal :show.sync="downshow" v-ref:modal backdrop="false">
      <header slot="modal-header" class="modal-header">
        <h4 class="modal-title">计划下发</h4>
      </header>
      <article slot="modal-body" class="modal-body">
        <div class="form-group">
          {{msg}}
        </div>
        <div class="form-group">
          <label class="label-control">下发日期</label>
          <datepicker  placeholder="下发日期" :value.sync="downDate"></datepicker>
        </div>
      </article>

      <footer slot="modal-footer" class="modal-footer">
        <button type="button" class="btn btn-success" @click='downConfirm()'>确认</button>
        <button type="button" class="btn btn-default" @click='close()'>取消</button>
      </footer>
    </modal>
    <modal :show.sync="uploadshow" v-ref:modal backdrop="false">
      <header slot="modal-header" class="modal-header">
        <button type="button" class="close" @click="close"><span>&times;</span></button>
        <h4 class="modal-title">文件上传</h4>
      </header>
      <article slot="modal-body" class="modal-body">
        <div class="form-group">
          <file-upload class="my-file-uploader" name="myFile"
                       action="rs/file/upload" tagname="文件上传" :headers="headers" multiple v-ref:file></file-upload>
        </div>
      </article>

      <footer slot="modal-footer" class="modal-footer">
      </footer>
    </modal>
    <modal :show.sync="isCovershow" v-ref:modal backdrop="false">
      <header slot="modal-header" class="modal-header">
        <button type="button" class="close" @click="isCoverClose"><span>&times;</span></button>
        <h4 class="modal-title">是否覆盖</h4>
      </header>
      <article slot="modal-body" class="modal-body">
        <div class="form-group">
          <p>是否覆盖之前的{{unhandplan.length}}条未抄表信息</p>
        </div>
      </article>

      <footer slot="modal-footer" class="modal-footer">
        <button v-show="show" type="button" class="btn btn-default" @click='unCover()'>取消</button>
        <button v-show="show" type="button" class="btn btn-success" @click='Cover()'>确认</button>
      </footer>
    </modal>
  </div>
</template>
<script>
  import { PagedList, HttpResetClass } from 'vue-client'
  import Vue from 'vue'
  import AppData from '../../../../stores/AppData'
  import * as Util from '../../../Util'
  import co from 'co'

  let downGen = function * (type, condition, data, self) {
    self.condition = condition
    self.msg = '确认下发计划'
    console.log('下发计划。。。', type, condition, data, self)
    // 判断之前是否有未抄表数据
    // let getUnhand = null
    // let getUnhand = yield Vue.resetpost('rs/sql/getUnhand', {data: {startDate: self.startDate, condition: self.condition}}, {resolveMsg: null, rejectMsg: '获取未抄表数据异常!!'})
    if (type === 'single') {
      // getUnhand = yield Vue.resetpost('rs/sql/getUnhand', {data: {startDate: self.startDate, condition: condition}}, {resolveMsg: null, rejectMsg: '获取未抄表数据异常!!'})
      self.msg = `确认下发编号为： ${data.f_userinfo_id} 户计划`
    } else if (type === 'batch') {
      // let tempCondition = condition.replace("and f_meter_state = '未下发'", '')
      // console.log('去掉未下发状态..', tempCondition)
      // getUnhand = yield Vue.resetpost('rs/sql/getUnhand', {data: {startDate: self.startDate, condition: tempCondition}}, {resolveMsg: null, rejectMsg: '获取未抄表数据异常!!'})
      self.msg = `确认下发当前总计:  ${data}  户计划`
    }
    // console.log('获取未抄表数据.......', getUnhand)
    // for (let i = 0; i < getUnhand.data.length; i++) {
    //   let temp = {
    //     id: getUnhand.data[i].id,
    //     f_user_id: getUnhand.data[i].f_user_id
    //   }
    //   self.unhandplan.push(temp)
    // }
    // console.log('未抄表Id....', self.unhandplan)
    // if (getUnhand.data.length > 0) {
    //   self.msg = self.msg + `, 警告: 之前有 ${getUnhand.data.length} 条未抄表数据`
    // }
    self.downshow = true
  }

  export default {
    title: '抄表管理',
    data () {
      return {
        model: new PagedList('rs/sql/cardPeriodAlreadyIssued', 50, {orderitem: '"id"', startDate: 'this.model.startDate',
          endDate: 'this.model.endDate'}),
        changeModel: {
          f_inputtor: ''
        },
        isChange: false,
        meter_state: false, // 是否显示计划下发按钮
        downshow: false,
        uploadshow: false,
        unhandplan: [], // 之前是否有未抄表记录
        isCover: false, // 是否覆盖之前的未抄表记录
        isCovershow: false,
        downDate: Util.toStandardDateString(),
        //  downDate: Util.toStandardYearMonth().replace("-", ""),
        msg: '',
        condition: '',
        headers: {'username': Util.f.name, 'blodid': Util.guid()},
        meters: [
          {label: '全部', value: ''},
          {label: '机表', value: '机表'},
          {label: '远传表', value: '远传表'}
        ],
        meternumbers: [
          {label: '全部', value: ''},
          {label: '有表号', value: '有表号'},
          {label: '无表号', value: '无表号'}
        ],
        sources: [
          {label: '全部', value: ''},
          {label: '手动录入', value: '手动录入'},
          {label: '抄表导入', value: '抄表导入'}
        ],
        issueds: [
          {label: '全部', value: ''},
          {label: '手动下发', value: '手动下发'},
          {label: '未抄下发', value: '未抄下发'},
          {label: '失败下发', value: '失败下发'},
          {label: '异常下发', value: '异常下发'},
          {label: '底数异常下发', value: '底数异常下发'}
        ],
        //  f_meter_classify: ['机表'],
        orderDefault: 'id',
        orderFields: {
          f_userinfo_id: 'no'
        },
        filialeName: [],
        outletsname: [],
        outlet: '',
        filiale: '',
        filialetype: ''
      }
    },
    props: {
      startDate: {
        type: String
      },
      endDate: {
        type: String
      }
    },
    ready () {
      this.model.startDate = this.startDate
      this.model.endDate = this.endDate
      this.reflash()
    },
    methods: {
      search (datas) {
        this.changeCancel()
        this.meter_state = datas.condition.includes('未下发')
        if (!Util.f.parent.parent.name.includes('统一资源管理')) {
          datas.condition += ` and f_filiale = '${Util.f.f_fengongsi}'`
        }
        if (this.$refs.paged.$refs.criteria.model.f_meter_type) {
          datas.condition += ` and f_filiale = '${Util.f.f_fengongsi}'`
        }
        this.model.search(datas.condition, this.model)
      },
      selfSearch (datas) {
        this.changeCancel()
        this.meter_state = datas.condition.includes('未下发')
        if (!Util.f.parent.parent.name.includes('统一资源管理')) {
          datas.condition += ` and f_filiale = '${Util.f.f_fengongsi}'`
        }
        if (datas.model.f_meter_brand && datas.model.f_meter_brand.length > 0) {
          if (datas.model.f_meter_brand[0].f_meter_brand) {
            datas.condition = `${datas.condition} and f_meter_brand = '${datas.model.f_meter_brand[0].f_meter_brand}'`
          }
        }
        this.model.search(datas.condition, this.model)
      },
      searchGather (inputtor, state, num) {
        this.$refs.paged.$refs.criteria.model.f_inputtor = [inputtor]
        this.$refs.paged.$refs.criteria.model.f_meter_state = [state]
        this.$refs.paged.$refs.criteria.model.f_user_id = ''
        this.$refs.paged.$refs.criteria.model.f_userinfo_id = ''
        this.$refs.paged.$refs.criteria.model.f_address = ''
        this.reflash()
      },
      reflash () {
        console.log('子组件查询，，，', this.$refs.paged.$refs.criteria)
        if (this.filialetype !== '总公司') {
          this.$refs.paged.$refs.criteria.model.f_filiale = this.filiale
        }
        this.$refs.paged.$refs.criteria.search()
      },
      enter (index, row) {
        row.f_operator = Util.f.name
        row.f_filiale = Util.f.f_fengongsi
        row.f_outlets = Util.f.f_parentname

        if (row.f_tablebase && row.f_tablebase !== '') {
          Vue.set(row, 'state', '开始')
          row.http = new HttpResetClass()
          row.http.load('POST', 'rs/logic/cardEnter', {data: row}, {resolveMsg: null, rejectMsg: null}).then((data) => {
            console.log('抄表成功', data.data)
            row.f_meter_state = data.data.f_meter_state
            row.f_return_fee = data.data.f_return_fee
	    row.f_balance = data.data.f_balance
            row.state = '成功'
            this.$parent.search()
          }).catch((error) => {
            console.log('抄表失败')
            row.state = '失败'
            Vue.set(row, 'error', JSON.stringify(error))
          })
        }
      },
      clearError (row) {
        if (row.f_tablebase === 0) {
          row.f_tablebase = ''
        }
        Vue.set(row, 'error', null)
      },
      // 抄表员调整
      adjust () {
        // 首先查看是否有已录入的用户，如果有，就弹出提示框，提示重新输入查询条件，或撤销已录入
        this.isChange = true
      },
      fileUpload () {
        this.uploadshow = true
      },
      changeCancel () {
        this.isChange = false
        this.changeModel.f_inputtor = ''
      },
      // 删除这条计划
      delectHand (row) {
        this.$resetdelete('rs/entity/t_cardhand', row).then(() => {
          this.$dispatch('refresh', '删除计划', row)
        })
      },
      // 撤销录入
      cancelHand (row) {
        this.$showMessage('撤销后不可恢复，需要重新录入，确认撤销吗？', ['confirm', 'cancel']).then((res) => {
          if (res === 'confirm') {
            // 还原t_userfiles中的f_meter_base
            // 组织冲正数据
            let data = {
              id: row.id,
              f_haircut_gas: row.f_haircut_gas,
              f_remanent_gas: row.f_remanent_gas,
              f_user_id: row.f_user_id,
              f_meter_base: row.f_meter_base,
              f_balance: row.f_balance
            }
            data.newcorrent = {
              f_user_id: row.f_user_id,
              f_userinfo_id: row.f_userinfo_id,
              f_correct_type: '抄表冲正(卡表)',
              f_correct_id: row.id,
              f_base: row.f_tablebase,
              f_last_base: row.f_last_tablebase,
              f_correct_money: 0,
              f_correct_date: Util.toStandardTimeString(),
              f_correct_state: '有效',
              f_outlets: Util.f.f_parentname,
              f_filiale: Util.f.f_fengongsi,
              f_operator: Util.f.name
            }
            data.delplan = {
              f_userinfo_id: row.f_userinfo_id,
              f_hand_date: row.f_hand_date,
              f_return_fee: row.f_return_fee
            }
            data.newplan = {
              f_last_tablebase: row.f_last_tablebase,
              f_inputtor: row.f_inputtor,
              f_hand_date: row.f_hand_date,
              f_meter_state: '未抄表',
              f_price_id: row.f_price_id,
              f_user_id: row.f_user_id,
              f_userinfo_id: row.f_userinfo_id + '',
              f_user_name: row.f_user_name,
              f_user_type: row.f_user_type,
              f_gasproperties: row.f_gasproperties,
              f_address: row.f_address,
              f_meter_brand: row.f_meter_brand,
              f_meter_style: row.f_meter_style,
              f_meternumber: row.f_meternumber,
              f_filiale: Util.f.f_fengongsi,
              f_outlets: Util.f.f_parentname,
              f_operator: Util.f.name
            }
            // 还原t_handplan
            this.$resetpost('rs/logic/cardCancelReverse', {data: data}).then(() => {
              this.$dispatch('refresh')
            })
          }
        })
      },
      handReverse (row) {
        this.$showMessage('冲正后需要重新缴费，确认冲正吗？', ['confirm', 'cancel']).then((res) => {
          if (res === 'confirm') {
            // 还原t_userfiles中的f_meter_base
            let data = {
              sell_id: row.f_sell_id,
              handplan_id: row.id,
              userinfo_version: row.userinfo_version
            }
            data.cancel = {
              f_user_id: row.f_user_id,
              f_user_name: row.f_user_name,
              f_correct_type: '缴费冲正',
              f_correct_id: row.id,
              f_correct_cause: '机表缴费错误',
              f_correct_money: 0 - row.f_oughtfee,
              f_correct_state: '有效',
              f_correct_gas: 0 - row.f_oughtamount,
              f_operator: Util.f.name
            }
            // 还原t_handplan
            this.$resetpost('rs/logic/handReverse', {data: data}).then(() => {
              this.$dispatch('refresh')
            })
          }
        })
      },
      // 批量变更抄表员
      changeInputtor (inputtor) {
        this.$showMessage(`确认变更前请确认选择的事件区间和查询条件是否正确，确认变更当前 ${this.model.count} 户抄表员为 ${inputtor}`, ['confirm', 'cancel']).then((res) => {
          if (res === 'confirm') {
            let http = new HttpResetClass()
            http.load('POST', 'rs/logic/changeInputtor',
              {data: {startDate: this.startDate, endDate: this.endDate, condition: this.model.condition, inputtor: inputtor}}, {resolveMsg: null}).then((data) => {
                this.$showAlert(`总计变更 ${data.data} 户抄表员为 ${inputtor}`, 'success', 2000)
                this.model.loadPage(this.model.pageIndex)
                this.changeCancel()
                this.$dispatch('change-inputtor', '抄表员批量变更', this.model.count, inputtor)
              })
          }
        })
      },
      down (type, condition, data) {
        co(downGen(type, condition, data, this))
      },
      // 单条下发计划
      downHand (row) {
        this.down('single', `f_user_id = '${row.f_user_id}'`, row)
      },
      // 批量下发计划
      batchDownHand () {
        this.down('batch', this.model.condition, this.model.count)
      },
      // 下发确认
      downConfirm () {
        // 正式提交下发
        if (this.unhandplan.length === 0) {
          this.downshow = false
          this.confirmDownHand()
        } else {
          this.isCovershow = true
        }
      },
      isCoverClose () {
        this.downshow = true
        this.isCovershow = false
      },
      Cover () {
        // 关闭下发日期弹出框
        this.downshow = false
        this.isCovershow = false
        // 是否覆盖之前的未抄记录
        this.isCover = true
        this.confirmDownHand()
      },
      unCover () {
        this.downshow = false
        this.isCovershow = false
        this.isCover = false
        this.confirmDownHand()
      },
      confirmDownHand () {
        this.$resetpost('rs/logic/cardhand', {data: {downDate: this.downDate, startDate: this.startDate,
              endDate: this.endDate, condition: this.condition, f_operator: Util.f.name, isCover: true}}
          , {resolveMsg: null, rejectMsg: null}).then((res) => {
            // this.search({condition: this.condition || '1=1'})
            // 将缓存的未抄表ID数组置空
            this.unhandplan = []
            this.$dispatch('refresh')
            this.$showAlert(`全部下发,总计下发${res.data}户`, 'success', 2000)
        }).catch((error) => {
          this.$showAlert(`下发失败,请注意查看，失败原因：${error}`, 'danger', 0)
        })
      },
      // 关闭下发计划得弹出框
      close () {
        this.downshow = false
        if (this.uploadshow) {
          this.uploadshow = false
          // 讲选的文件清空
          this.$refs.file.$el.querySelector('input').value = ''
        }
      },
      // 判断当前登陆人是不是子公司的人员
      isHead () {
        return Util.f.parent.parent.name.includes('统一资源管理')
      },
      sort (field, rule) {
        // 将所有排序方式设为不排序，实现相互排斥
        for (let key in this.orderFields) {
          if (key === field) {
            this.orderFields[key] = rule
          } else {
            this.orderFields[key] = 'no'
          }
        }
        // 如果新规则不排序，还原为默认排序
        if (rule === 'no') {
          this.model.paramSource.orderitem = `'${this.orderDefault}'`
        } else {
          this.model.paramSource.orderitem = `'${field} ${rule}'`
        }

        this.reflash()
      }
    },
    computed: {
      inputtores () {
        return [{label: '全部', value: ''}, ...AppData.getParam('抄表员')]
      },
      meterstates () {
        return [{label: '全部', value: ''}, ...AppData.getParam('抄表状态')]
      },
      filialeArr () {
        let condition = this.filialetype === '总公司' ? '' : this.filiale
        return [{label: '全部', value: condition}, ...this.filialeName]
      },
      outletArr () {
        return [{label: '全部', value: ''}, ...this.outletsname]
      },
      usertypes () {
        return [{label: '全部', value: ''}, ...AppData.getParam('用户类型')]
      },
      filiales () {
        let rs = []
        for (let i = 0; i < Util.f.f_allfiliale.length; i++) {
          rs.push({label: Util.f.f_allfiliale[i].label, value: Util.f.f_allfiliale[i].label})
        }
        return [{label: '全部', value: ''}, ...rs]
      },
      outlets () {
        let rs = []
        console.log('档案营业网点。。。', this.$refs.paged.$refs.criteria.model.f_filiale)
        if (this.$refs.paged.$refs.criteria.model.f_filiale.length > 0) {
          for (let i = 0; i < Util.f.f_allfiliale.length; i++) {
            if (Util.f.f_allfiliale[i].label === this.$refs.paged.$refs.criteria.model.f_filiale[0]) {
              rs = Util.f.f_allfiliale[i].value
            }
          }
        }
        console.log('获取档案营业网点。。。。', rs)
        return [{label: '全部', value: ''}, ...rs]
      },
      whetherpaies () {
        // return [{label: '全部', value: ''}, ...AppData.getParam('缴费状态')]
        return [
          {label: '全部', value: ''},
          {label: '已缴费', value: '是'},
          {label: '未缴费', value: '否'}
        ]
      },
      // 校验日期输入格式
      dateError () {
        // 校验是不是纯数字
        if (!(/^[0-9]+$/.test(this.downDate))) {
          return true
        }
        // 校验是不是6位长度
        if (this.downDate.length !== 6) {
          return true
        }
        // let year = this.downDate.substring(0, 4)
        let month = this.downDate.substring(4, 6)
        // 月份是不是符合
        if ((month - 0) > 12 && (month - 0) < 1) {
          return true
        }
        return false
      },
      getStartAndEnd () {
        return Util.toStartAndEndDateString()
      },
      firestates () {
        return [
          {label: '全部', value: ''},
          {label: '已点火', value: '1'},
          {label: '未点火', value: '0'}
        ]
      },
      brand () {
        return [{label: '全部', value: {f_meter_brand: '', gasmodel: [{label: '全部', value: {f_meter_style: ''}}]}}, ...AppData.getGasbrand()]
      }
    },
    watch: {
      'startDate' (val) {
        console.log('观察到开始时间', val)
        this.model.startDate = val
      },
      'endDate' (val) {
        console.log('观察到结束时间', val)
        this.model.endDate = val
      }
      // 'f_meter_classify' (val) {
      //   if (val[0] !== '') {
      //     this.model.f_meter_classify = `u.f_meter_classify = '${val[0]}' `
      //   }else {
      //     this.model.f_meter_classify = '1=1'
      //   }
      // }
    },
    events: {
      onFileUpload: function (file, res) {
        let data = {
          // configpath: 'hibernate/用户档案/userinfo.hbm.xml',
          model: {
            f_operator: Util.f.name,
            f_end_date: Util.nextMonth20(Util.toStandardTimeString())
          },
          filepath: res.path
        }
        // console.log('2222223333333333333', data.filepath)
        // 获取filename 判断是先锋还是伦力，之后有还可在加
        // console.log('1111111111', data.filepath)
        if (data.filepath.includes('先锋')) {
          this.$resetpost('rs/logic/xfimport', data, {resolveMsg: null, rejectMsg: '上传失败'}, 0).then((res) => {
            // console.log('终于成功了', res)
            this.uploadshow = false
            this.$showAlert(`一共上传${res.data.total}条数据, 成功${res.data.successnum}条, 未抄下发${res.data.nohandnum}条, 失败下发${res.data.failednum}条, 异常下发${res.data.exceptionnum}条`, 'success', 2000)
            this.$parent.search()
          })
        } else if (data.filepath.includes('伦力')) {
          this.$resetpost('rs/logic/llimport', data, {resolveMsg: null, rejectMsg: '上传失败'}, 0).then((res) => {
            // console.log('终于成功了', res)
            this.uploadshow = false
            this.$showAlert(`一共上传${res.data.total}条数据, 成功${res.data.successnum}条, 未抄下发${res.data.nohandnum}条, 失败下发${res.data.failednum}条, 异常下发${res.data.exceptionnum}条`, 'success', 2000)
            this.$parent.search()
          })
        }
      }
    }
  }
</script>
<style lang="less">
  #handManager {
    display: flex;
    justify-content: space-around;
    align-items: center;
    .btn {
      margin: 0px;
    }
  }
  .hand-loading {
    border: 3px solid #ccc;
    border-right-color: #337ab7;
    border-radius: 50%;
    animation: spin 0.6s linear;
    position: absolute;
    animation-iteration-count: infinite;
    top: 0;
    right: 50%;
    z-index: 2;
    display: block;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    pointer-events: none;
  }
  @keyframes spin {
    100% {
      transform: rotate(360deg);
    }
  }
</style>
